<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.savtrans}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
        <h:form prependId="false">

           <script type="text/javascript">  
                         
                function handleSaveSavtrans(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgSavtrans.hide();  
                    }  
                }
                
                function handleDeleteSavtrans(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgDelSavtrans.hide();  
                    }  
                }
                
                function componenKeyPress(e) {
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if(code==13) {
                        
                       e.preventDefault ? e.preventDefault() : e.returnValue = false;
                       e.stopPropagation();
                    }
                }
                
            </script>  

            <p:toolbar>
                <p:toolbarGroup align="left">
                    <!--p:commandButton value="#{bundle.btnNew}"
                                     icon="ui-icon-document"
                                     action="#{savtransBean.newData()}"  
                                     oncomplete="dlgSavtrans.show()"
                                     update="displaySavtrans"> 
                    </p:commandButton-->

                    <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgSavtrans.show()"
                                     icon="ui-icon-disk" actionListener="#{savtransBean.openData()}"
                                     rendered="#{menuBean.cekButtonAccess(163,'OPN;')}"
                                     update="displaySavtrans" >
                    </p:commandButton>

                    <!--p:commandButton type="button" value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                     onclick="dlgDelSavtrans.show()"
                                     update="displaySavtrans" /> 

                    <p:commandButton type="button" value="#{bundle.btnPrint}" icon="ui-icon-print">
                        <p:printer target="dtSavtranss" />  
                    </p:commandButton-->
                    
                </p:toolbarGroup>
            </p:toolbar>
            <br />
            <p:dataTable var="savtrans" value="#{savtransBean.savtranses}" id="dtSavtranss"
                         selection="#{savtransBean.selectedData}" selectionMode="single" rowIndexVar="noUrut"
                         rowKey="#{savtrans.savtransId}" sortBy="#{savtrans.transCode}"
                         paginator="true" rows="15" paginatorPosition="bottom">
                <p:column style="width:15px;"> 
                    <f:facet name="header">No</f:facet>
                    <h:outputText value="#{noUrut+1}" />
                </p:column>
                <p:column style="width:auto" sortBy="#{savtrans.transCode}">
                    <f:facet name="header">#{bundle.globalCode}</f:facet>
                    <h:outputText value="#{savtrans.transCode}" />
                </p:column>
                
                <p:column style="width:auto" sortBy="#{savtrans.transName}">
                    <f:facet name="header">#{bundle.globalName}</f:facet>
                    <h:outputText value="#{savtrans.transName}" />
                </p:column>
                
            </p:dataTable>
          
            <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                             header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelSavtrans">
                <h:panelGrid cellspacing="0" cellpadding="0" styleClass="pComBtnD">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnYes}" update="dtSavtranss" 
                                         oncomplete="handleDeleteSavtrans(xhr, status, args)"  
                                         actionListener="#{savtransBean.delete()}" />  
                        <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelSavtrans.hide()" type="button" />  
                    </f:facet>
                </h:panelGrid>  
            </p:confirmDialog> 

            <p:dialog header="#{bundle.savtrans}" widgetVar="dlgSavtrans" closable="true"
                      dynamic="true">
                <p:ajax event="close" listener="#{savtransBean.handleClose}"/>
                <h:panelGrid id="displaySavtrans" columns="3" styleClass="addELIT">
                    <h:outputLabel value= "#{bundle.globalCode}" /><h:outputLabel value=":" />
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{savtransBean.unsaveData!=null}" >
                        <p:inputText value="#{savtransBean.unsaveData.transCode}" 
                                     size="25" onkeydown="componenKeyPress(event)" label="#{bundle.globalCode}" required="true" 
                                     requiredMessage="#{bundle.globalCode} #{bundle.requiredInput}" id="savtransCode1">
                            <p:ajax event="keyup" update="msgsavtransCode1" />
                        </p:inputText>
                        <p:message id="msgsavtransCode1" for="savtransCode1" display="icon" />
                    </h:panelGrid>
                    
                    <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.globalName}" /><h:outputLabel value=":" />
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{savtransBean.unsaveData!=null}" >
                        <p:inputText value="#{savtransBean.unsaveData.transName}" readonly="true"
                                     size="25" onkeydown="componenKeyPress(event)" label="#{bundle.globalName}" required="true" 
                                     requiredMessage="#{bundle.globalName} #{bundle.requiredInput}" id="savtransName1">
                            <p:ajax event="keyup" update="msgsavtransName1" />
                        </p:inputText>
                        <p:message id="msgsavtransName1" for="savtransName1" display="icon" />
                    </h:panelGrid>
                        
                </h:panelGrid>
                
                
                <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{savtransBean.save()}"
                                         update="dtSavtranss" widgetVar="submitSavtrans"
                                         oncomplete="handleSaveSavtrans(xhr, status, args)"/>
                        <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgSavtrans.hide()" icon="ui-icon-document" 
                                         process="@this">
                            <pe:resetEditableValues for="displaySavtrans"/>  
                        </p:commandButton>
                    </f:facet>
                </h:panelGrid>
            </p:dialog> 
        </h:form>
        </ui:composition>    
    </h:body>
</html>